<template lang="pug">
.main
  .banner(:style="{backgroundImage:`url(${banner})`}")
    p 公司动态
  .section
    .right
      el-card.item(v-for="(i,n) in newsData" :key="n")
        .title
          span(@click="openWeb('/index/'+i.id)") {{i.title}}
          font {{i.createTime}}
        .content {{i.summary}}
      .paging(v-if="filter.page.totalPage>=2")
        el-pagination(background layout="prev, pager, next" :page-count="filter.page.totalPage" @current-change="changePage")
    .left
      el-card.item
        .title
          span 财经要闻
          font(@click="$router.push('/cjyw')") 更多
        .content
          .lists(v-for="(i,n) in newsData2" :key="n" @click="openWeb('/index/'+i.id)" :title="i.title") {{i.title}}
      el-card.item
        .title
          span 税务要闻
          font(@click="$router.push('/swyw')") 更多
        .content
          .lists(v-for="(i,n) in newsData3" :key="n" @click="openWeb('/index/'+i.id)" :title="i.title") {{i.title}}
      el-card.item
        .title
          span 地方资讯
          font(@click="$router.push('/dfzx')") 更多
        .content
          .lists(v-for="(i,n) in newsData4" :key="n" @click="openWeb('/index/'+i.id)" :title="i.title") {{i.title}}

</template>

<script>
export default {
  components: {},
  data() {
    return {
      index: 0,
      newsData: [],
      newsData2: [],
      newsData3: [],
      newsData4: [],
      filter: {
        page: {
          pageNumber: 1,
          pageSize: 6,
          totalPage: 1
        },
        categorys: ["公司动态"],
        state: 2
      },
      ossBaseUrl:'http://huaban-web.oss-cn-beijing.aliyuncs.com/huaban-enterprise/',
      banner: require("@/assets/index/banner.png"),
    };
  },
  computed: {},
  methods: {
    openWeb(val) {
      window.open("/enterprise" + val)
    },
    getData() {
      this.$API
        .post("/articlelist/query", this.filter).then(res => {
          var div = document.createElement('div')
          this.newsData = res.list.map(item => {
              div.innerHTML = item.summary;
              item.summary = div.innerText;
              item.summary = item.summary.replace(/\s/g,"");
              var date = new Date(item.createTime);
              item.createTime =
                date.getFullYear() +
                "-" +
                (date.getMonth()<9?'0'+(date.getMonth()+1): (date.getMonth()+1)) +
                "-" +
                date.getDate();
              return item
          });
          this.filter.page.totalPage = res.totalPage;
          
        });
      this.$API
        .post("/article/query", {
          page: {
            pageSize: 5,
            pageNumber: 1,
            totalSize: 100
          },
          categorys: ["财经要闻"],
          state: 2
        })
        .then(res => {
          this.newsData2 = res.list;
        });
      this.$API
        .post("/article/query", {
          page: {
            pageSize: 5,
            pageNumber: 1,
            totalSize: 100
          },
          categorys: ["税务要闻"],
          state: 2
        })
        .then(res => {
          this.newsData3 = res.list;
        });
      this.$API
        .post("/article/query", {
          page: {
            pageSize: 5,
            pageNumber: 1,
            totalSize: 100
          },
          categorys: ["地方资讯"],
          state: 2
        })
        .then(res => {
          this.newsData4 = res.list;
        });
    },
    changePage(val){
      this.filter.page.pageNumber = val;
      this.getData()
    }
  },
  created() {
    this.getData()
  },
  mounted() {}
};
</script>

<style lang="less" scoped>
@c1: #2a315b;
@c2: #4b61f0;
@c3: #dedede;
@c4: #f1f2f7;
@c5: #ca9247;

.main {
  background-color: #f1f2f7;
}
.banner {
  position: relative;
  background-position: top;
  height: 260px;
  .center;
  .size(4em;);
  p {
    color: @white;
    padding-top: 110px;
    letter-spacing: 4px;
    animation: fadeInUp 1.2s ease;
  }
}

.section {
  .mCenter;
  padding-top: 30px;
  width: 1200px;
  padding-bottom: 40px;
  .sectionTitle {
    span {
      border-bottom: 4px solid @primary;
    }
  }
}

.right, .left {
  .inline;
  //- .border;
  text-align: left;
  letter-spacing: 1px;
  vertical-align: top;
}
.right {
  width: 70%;
  margin-right: 2%;
  .item {
    width: 100%;
    margin-top: 12px;
    padding: 0 38px;
    letter-spacing: 1px;
    &:nth-of-type(1) {
      margin: 0;
    }
    .title {
      .lh(30px);
      .pointer;
      position: relative;
      span {
        .inline;
        .size(22px);
        color: #333;
        position: absolute;
        &:before {
          content: "";
          position: absolute;
          width: 100%;
          height: 2px;
          bottom: 0;
          left: 0;
          background-color: #000;
          visibility: hidden;
          transform: scaleX(0);
          transition-duration: 0.2s;
          transition-timing-function: ease-in-out;
          transition-delay: 0s;
        }
        &:hover::before {
          visibility: visible;
          transform: scaleX(1);
        }
      }
      font {
        position: absolute;
        top: 5px;
        right: 0;
        color: #999;
      }
    }
    .content {
      .lh(30px);
      .size(17px);
      width: 100%;
      color: #21303F;
      text-indent: 2em;
      margin-top: 40px;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
      margin-bottom: 4px;
    }
  }
  .paging {
    .center;
    width: 100%;
    margin: 12px;
  }
}
.left {
  width: 28%;
  .item {
    height: 260px;
    margin-top: 24px;
    &:nth-of-type(1) {
      margin: 0;
    }
    .title {
      padding: 0 8px;
      position: relative;
      border-left: 5px solid @primary;
      span {
        .size(18px);
      }
      font {
        position: absolute;
        .pointer;
        .size(14px);
        top: 4px;
        right: 8px;
        color: #999;
        transition: all .3s ease;
        &:hover {
          color: #696969;
        }
      }
    }
    .content {
      width: 100%;
      margin-top: 10px;
      padding-top: 12px;
      border-top: 1px outset @primary;
      .lists {
        .lh(33px);
        .pointer;
        width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        letter-spacing: 1px;
        &:hover {
          color: @primary; 
        }
        &::before {
          content: "●";
          .size(12px);
          color: #747070;
          margin-right: 4px;
        }
      }
    }
  }
}

</style>